package practise.mulitThreads.ConcurrentInPractice.secondTime.pageRender;

import java.util.concurrent.*;

/**
 * Created by Richard on 7/28/2014.
 */
public class PageRender {

    public void rend(String[] params){
        Page page = new Page();
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        CompletionService<String> completionService = new ExecutorCompletionService<>(executorService);
        for(String param:params){
            completionService.submit(new PageContentDownloader(param));
        }
       downLoadTextContent(params,page);
        for(String param:params){
            try {
                page.addContent(completionService.take().get());
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        }

    }

    public void downLoadTextContent(String[] params,Page page){

    }
}
